<?php
namespace Home\Controller;
use Think\Controller;
class DetailController extends CommonController {
    public function index(){
       //检测登录
        if(empty($_SESSION['id'])){
            $islogin = 'true';
        }else{
            $islogin = $_SESSION['id'];
        }
        // var_dump($_GET);
        $cid=$_GET['cid'];
        if(is_numeric($cid)){
            $isnumber = 'cid';
        }else{
            $isnumber = 'keywords';
        }

    	//接受食物id
    	 $id = $_GET['fid'];
         //创建食物模板
         $Foods = M('mvp_foods');
         


         //接收星级
         $score = $_GET['score'];
         //接收类id
         // $cid = $_GET['cid'];
         //接收优惠的价格
         if(empty($_GET['sellprice'])){
            $sellprice = 0;
         }else{
            $sellprice = $_GET['sellprice'];
         }

         // var_dump($_GET);die;
    	 
    	 //查询数据
    	 $finfo = $Foods->where('id='.$id)->find();
    	 // echo $Foods->_sql();
    	 // var_dump($finfo);die;
         $finfo['score'] = $score;
         $finfo['sellprice'] = $sellprice;
         // var_dump($finfo);
         //创建评论模板
         $comment = M('mvp_comment');
         //根据食物查询
         $cinfo = $comment->where('fid='.$id)->join('mvp_user on mvp_comment.uid=mvp_user.id')->select();
         // echo $comment->_sql();
          // var_dump($cinfo);die;
    	 //分配变量
         $this->assign('finfo',$finfo);
         $this->assign('cinfo',$cinfo);
         $this->assign('islogin',$islogin);
         $this->assign('isnumber',$isnumber);
    	 $this->assign('cid',$cid);
    	$this->display();
    }
}